﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using HomeCareLibrary.Core.Dtos;
using HomeCareLibrary.DataAccess;

namespace HomeCareLibrary.AppService.Mappers
{
    /// <summary>
    /// Assembler for <see cref="CTGetMoSpecialFeaturesArticles"/> and <see cref="CTGetMonthlySpecialFeaturesArticlesDto"/>.
    /// </summary>
    public static partial class CTGetMonthlySpecialFeaturesArticlesMapper
    {
        /// <summary>
        /// Invoked when <see cref="ToDTO"/> operation is about to return.
        /// </summary>
        /// <param name="dto"><see cref="CTGetMonthlySpecialFeaturesArticlesDto"/> converted from <see cref="CTGetMoSpecialFeaturesArticles"/>.</param>
        static partial void OnDTO(this CTGetMoSpecialFeaturesArticles entity, CTGetMonthlySpecialFeaturesArticlesDto dto);

        /// <summary>
        /// Invoked when <see cref="ToEntity"/> operation is about to return.
        /// </summary>
        /// <param name="entity"><see cref="CTGetMoSpecialFeaturesArticles"/> converted from <see cref="CTGetMonthlySpecialFeaturesArticlesDto"/>.</param>
        static partial void OnEntity(this CTGetMonthlySpecialFeaturesArticlesDto dto, CTGetMoSpecialFeaturesArticles entity);

        /// <summary>
        /// Converts this instance of <see cref="CTGetMonthlySpecialFeaturesArticlesDto"/> to an instance of <see cref="CTGetMoSpecialFeaturesArticles"/>.
        /// </summary>
        /// <param name="dto"><see cref="CTGetMonthlySpecialFeaturesArticlesDto"/> to convert.</param>
        public static CTGetMoSpecialFeaturesArticles ToEntity(this CTGetMonthlySpecialFeaturesArticlesDto dto)
        {
            if (dto == null) return null;

            var entity = new CTGetMoSpecialFeaturesArticles();
            
            entity.article_detail= dto.article_detail;
            entity.article_summary = dto.article_summary;
            entity.article_small_image_url = dto.article_small_image_url;

            dto.OnEntity(entity);

            return entity;
        }

        /// <summary>
        /// Converts this instance of <see cref="CTGetMoSpecialFeaturesArticles"/> to an instance of <see cref="CTGetMonthlySpecialFeaturesArticlesDtos"/>.
        /// </summary>
        /// <param name="entity"><see cref="CTGetMoSpecialFeaturesArticles"/> to convert.</param>
        public static CTGetMonthlySpecialFeaturesArticlesDto ToDTO(this CTGetMoSpecialFeaturesArticles entity)
        {
            if (entity == null) return null;

            var dto = new CTGetMonthlySpecialFeaturesArticlesDto();            

            dto.article_detail = entity.article_detail;
            dto.article_summary = entity.article_summary;
            dto.article_small_image_url = entity.article_small_image_url;

            entity.OnDTO(dto);

            return dto;
        }

        /// <summary>
        /// Converts each instance of <see cref="CTGetMonthlySpecialFeaturesArticlesDto"/> to an instance of <see cref="CTGetMoSpecialFeaturesArticles"/>.
        /// </summary>
        /// <param name="dtos"></param>
        /// <returns></returns>
        public static List<CTGetMoSpecialFeaturesArticles> ToEntities(this IEnumerable<CTGetMonthlySpecialFeaturesArticlesDto> dtos)
        {
            if (dtos == null) return null;

            return dtos.Select(e => e.ToEntity()).ToList();
        }

        /// <summary>
        /// Converts each instance of <see cref="CTGetMoSpecialFeaturesArticles"/> to an instance of <see cref="CTGetMonthlySpecialFeaturesArticlesDto"/>.
        /// </summary>
        /// <param name="entities"></param>
        /// <returns></returns>
        public static List<CTGetMonthlySpecialFeaturesArticlesDto> ToDTOs(this IEnumerable<CTGetMoSpecialFeaturesArticles> entities)
        {
            if (entities == null) return null;

            return entities.Select(e => e.ToDTO()).ToList();
        }
    }
}
